#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
#define int long long
typedef pair<int, int> PII;
int n, k;
struct node {
    int l, r, c;
} a[N];
int res[N];
signed main() {
    int T;
    cin >> T;
    while (T--) {
        cin >> n;
        map<PII, int> mp;
        priority_queue<int, vector<int>, greater<int> > L;
        priority_queue<int, vector<int>, greater<int> > R;
        for (int i = 1; i <= n; i++) {
            scanf("%lld%lld%lld", &a[i].l, &a[i].r, &a[i].c);
        }
        int now = a[1].c;
        cout << now << endl;
        int l = a[1].l, r = a[1].r;
        mp[{l, r}] = a[1].c;
        L.push(a[1].c);
        R.push(a[1].c);
        for (int i = 2; i <= n; i++) {
            if (mp[{a[i].l, a[i].r}]) {
                mp[{a[i].l, a[i].r}] = min(a[i].c, mp[{a[i].l, a[i].r}]);
            } else
                mp[{a[i].l, a[i].r}] = a[i].c;
            if (a[i].l < l) {
                while (L.size()) {
                    L.pop();
                }
                L.push(a[i].c);
            } else if (a[i].l == l) {
                L.push(a[i].c);
            }
            if (a[i].r > r) {
                while (R.size()) {
                    R.pop();
                }
                R.push(a[i].c);
            } else if (a[i].r == r) {
                R.push(a[i].c);
            }

            l = min(l, a[i].l);
            r = max(r, a[i].r);
            if (mp[{l, r}]) {
                now = min(L.top() + R.top(), mp[{l, r}]);
            } else {
                now = L.top() + R.top();
            }
            cout << now << endl;
        }
    }
}